package com.dsh.storeManagement.controller;

import com.dsh.model.Result;
import com.dsh.storeManagement.entity.vo.*;
import com.dsh.storeManagement.service.AdminFranchiseLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "商品分类和加盟等级与折扣的关系")
@RestController
@RequestMapping("adminFranchiseLevel")
public class AdminFranchiseLevelController {
    @Resource
    private AdminFranchiseLevelService adminFranchiseLevelService;
    @ApiOperation("查看等级商品对应的折扣")
    @GetMapping("selectDiscount")
    public Result selectDiscount() {
        List<AdminFranchiseLevelVo> adminFranchiseLevelVos = adminFranchiseLevelService.selectDiscount();
        return Result.success(adminFranchiseLevelVos,"");
    }
    @ApiOperation("修改折扣")
    @PostMapping("updateDiscount")
    public Result updateDiscount(@RequestBody UpdateDiscountVo updateDiscountVo){
        int i = adminFranchiseLevelService.updateDiscount(updateDiscountVo);
        return Result.success(i,"");
    }
    @ApiOperation("新增加盟分類")
    @PostMapping("insertFranchise")
    public  Result insertFranchise(@RequestBody FranchiseLevelVo franchiseLevelVo){
        int i = adminFranchiseLevelService.insertFranchise(franchiseLevelVo);
        return Result.success(i,"");
    }

}
